<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>逻辑与操作示例</title>
    <style>
        body {
            font-family: 'Arial', sans-serif;
            background-color: #f0f4f8;
            margin: 0;
            padding: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
        }

        .container {
            background-color: #ffffff;
            padding: 30px;
            width: 400px;
            border-radius: 10px;
            box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
            text-align: center;
        }

        h1 {
            color: #333;
            font-size: 26px;
            margin-bottom: 20px;
        }

        .input-container {
            margin-bottom: 20px;
        }

        .input-container label {
            font-size: 18px;
            color: #333;
            margin-right: 10px;
        }

        .input-container select {
            padding: 10px;
            font-size: 16px;
            margin: 10px 0;
            border-radius: 5px;
            border: 2px solid #ccc;
        }

        .button {
            padding: 12px 25px;
            background-color: #007BFF;
            color: white;
            border: none;
            font-size: 18px;
            border-radius: 5px;
            cursor: pointer;
            transition: background-color 0.3s ease;
        }

        .button:hover {
            background-color: #0056b3;
        }

        .result {
            font-size: 20px;
            margin-top: 20px;
            font-weight: bold;
        }

        .result.true {
            color: green;
        }

        .result.false {
            color: red;
        }

        .info {
            margin-top: 20px;
            font-size: 14px;
            color: #777;
        }
    </style>
</head>

<body>
    <div class="container">
        <h1>逻辑与操作</h1>
        <p>选择两个布尔值进行逻辑与（AND）操作：</p>

        <div class="input-container">
            <label for="valueA">布尔值 A:</label>
            <select id="valueA">
                <option value="true">真</option>
                <option value="false">假</option>
            </select>
        </div>

        <div class="input-container">
            <label for="valueB">布尔值 B:</label>
            <select id="valueB">
                <option value="true">真</option>
                <option value="false">假</option>
            </select>
        </div>

        <button class="button" onclick="performAndOperation()">计算结果</button>

        <div class="result" id="result"></div>

        <div class="info">
            <p>逻辑与操作规则：只有两个布尔值都为“真”时，结果才为“真”。</p>
        </div>
    </div>

    <script>
        // 定义逻辑与函数
        const and = (a, b) => a && b;

        // 执行逻辑与操作
        function performAndOperation() {
            const valueA = document.getElementById('valueA').value === 'true';
            const valueB = document.getElementById('valueB').value === 'true';

            // 调用and函数
            const result = and(valueA, valueB);

            // 显示结果
            const resultDiv = document.getElementById('result');
            if (result) {
                resultDiv.textContent = '结果：真';
                resultDiv.classList.add('true');
                resultDiv.classList.remove('false');
            } else {
                resultDiv.textContent = '结果：假';
                resultDiv.classList.add('false');
                resultDiv.classList.remove('true');
            }
        }
    </script>
</body>

</html>